/**
 * @Author：ming
 * @Date：2023/10/2 9:39 PM
 * @Filename：Hj8
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author ming
 */
public class Hj20 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str ;
        while ((str=br.readLine())!=null){
            if(isOk(str)){
                System.out.println("OK");
            }else {
                System.out.println("NG");
            }
        }

    }

    public static boolean isOk(String s){
        if(s.length()<8){
            return false;
        }

        int up = 0;
        int low = 0;
        int digit =0;
        int other = 0;

        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            if(c>='0'&&c<='9'){
                digit = 1;
            }else if(c>='a'&&c<='z'){
                low = 1;
            }else if(c>='A'&&c<='Z'){
                up = 1;
            }else {
                other=1;
            }
        }
        if(up+low+digit+other<3){
            return false;
        }

        int len = s.length();
        char[] cc = s.toCharArray();

        for (int i = 0; i < len-5; i++) {
            for (int j = i+3; j < len-2; j++) {
                if(cc[i]==cc[j]&&cc[i+1]==cc[j+1]&&cc[i+2]==cc[j+2]){
                    return false;
                }
            }
        }

        return true;


    }
}
